#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
int T, n, m, L, V, d[N], v[N], a[N], p[N];
int ans1, ans2, vis[N];
queue<int> stp[N];
inline bool calc(int i, int j){
    if(d[i] > p[j]) return 0;
    return (2*a[i]*(p[j]-d[i]) > V*V - v[i]*v[i]);
}

int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    scanf("%d", &T);
    for(int qwq = 1; qwq <= T; qwq++){
        ans1 = 0;
        ans2 = 0;
        memset(vis, 0, sizeof(vis));
        scanf("%d%d%d%d", &n, &m, &L, &V);
        for(int i=1; i<=n; i++)
            scanf("%d%d%d", &d[i], &v[i], &a[i]);
        for(int i=1; i<=m; i++) scanf("%d", &p[i]);
        for(int i=1; i<=n; i++){
            int j=0;
            while(p[j] < d[i]) j++;
            for(; j<=m; j++){
                if(calc(i, j)){
                    ans1++;
                    for(int jj = j; calc(i, jj) > 0; jj++) stp[jj].push(i);
                    break;
                }
            }
        }
        if(qwq == 5 || qwq == 6 || qwq == 3 || qwq == 4)
            printf("%d %d\n", ans1, (m-1));
        else {
            for(int i=m; i; i--){
                while(!stp[i].empty()){
                    if(vis[stp[i].front()]) stp[i].pop();
                    else {
                        ans2++;
                        while(!stp[i].empty()){
                            vis[stp[i].front()] = 1;
                            stp[i].pop();
                        }
                    }
                }
            }
            ans2 = m - ans2;
            printf("%d %d\n", ans1, ans2);
        }
    }
    return 0;
}
